//
//  WordErrorCell.m
//  JPWords
//
//  Created by 梁淑婷 on 2024/6/29.
//

#import "WordErrorCell.h"

@interface WordErrorCell()
@property(nonatomic,strong)UIImageView *selImageView;
@property(nonatomic,strong)UILabel *titleLabel;
@end

@implementation WordErrorCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.contentView.backgroundColor = [UIColor whiteColor];
 
    __weak typeof(self)weakSelf = self;
    self.selImageView = [[UIImageView alloc]init];
    self.selImageView.image = [UIImage imageNamed:@"word_error_reason_unsel"];
    [self.contentView addSubview:self.selImageView];
    [self.selImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@16);
        make.height.width.mas_equalTo(@18);
        make.centerY.mas_equalTo(weakSelf.contentView);
    }];
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.font = JPUIFontPingFangSCRegular(15);
    self.titleLabel.textColor = KFontGrayColor;
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.selImageView.mas_right).offset(12);
        make.height.mas_equalTo(@21);
        make.right.mas_equalTo(@-16);
        make.centerY.mas_equalTo(weakSelf);
    }];
    
    
}

-(void)setModel:(FeedbackListModel *)model{
    self.titleLabel.text = model.dictDataName;
}

-(void)setIsSel:(BOOL)isSel{
    _isSel = isSel;
    if(isSel == YES){
        self.selImageView.image = [UIImage imageNamed:@"word_error_reason_sel"];
    }else{
        self.selImageView.image = [UIImage imageNamed:@"word_error_reason_unsel"];
    }
}


@end
